from django.db import models
from apps.utils.base_model import BaseModel


class Order(BaseModel):
    """ 支付订单记录表 """

    out_trade_no = models.CharField(
        max_length=255,
        null=False,
        default="",
        db_index=True,
        verbose_name="微信支付订单号",
        help_text="微信支付订单号",
    )

    prepay_id = models.CharField(
        max_length=255,
        null=False,
        default="",
        blank=True,
        verbose_name="微信支付预支付交易会话标识",
        help_text="微信支付预支付交易会话标识",
    )

    transaction_id = models.CharField(
        max_length=255,
        null=False,
        blank=True,
        default="",
        verbose_name="微信支付交易号",
        help_text="微信支付交易号",
    )

    total_amount = models.DecimalField(
        max_digits=10,
        decimal_places=2,
        default=0,
        null=False,
        blank=False,
        verbose_name="支付金额",
        help_text="支付金额",
    )

    status = models.CharField(
        max_length=255,
        null=False,
        default="",
        blank=True,
        verbose_name="交易状态",
        help_text="交易状态",
    )

    status_desc = models.CharField(
        max_length=255,
        null=False,
        blank=True,
        default="",
        verbose_name="交易状态描述",
        help_text="交易状态描述",
    )

    blank_type = models.CharField(
        max_length=255,
        null=False,
        blank=True,
        default="",
        verbose_name="付款银行",
        help_text="付款银行",
    )

    pay_time = models.DateTimeField(
        null=False,
        blank=False,
        default=None,
        verbose_name="交易完成时间",
        help_text="交易完成时间",
    )

    class Meta:
        db_table = "red_envelop_orders"
